#
# http://code.google.com/p/fabricate
#
import os
import glob

def build():
  builduis()
  buildtrans()
  buildres()
  Setup()

# Compile the GUIs.
def builduis():
  fl = glob.glob('ui/*.ui')
  for f in fl:
     ui = os.path.splitext(os.path.split(f)[1])[0]
     print('Compiling: ' + f)
     os.system('pyuic4 -x -o ui/Ui_' + ui + '.py' + ' ui/' + ui + '.ui')

# Translations. Create the .ts and .qm files.
def buildtrans():
    print('Update translations...')
    os.system('pylupdate4 -verbose Vondel.pro')
    tr = glob.glob('translations/*.ts')
    for f in tr:
        print('lrelease: ' + f)
        os.system('lrelease ' + f)

# Resources.
def buildres():
    res = glob.glob('*.qrc')
    for f in res:
        rs = os.path.splitext(os.path.split(f)[1])[0] + '_rc.py'
        print('Building resource ' + f + ' to ' + rs)
        os.system('pyrcc4 -py3 ' + f  + ' -o ' + rs)

# Freeze.
def Setup():
    pass
    #os.system('setup.py build')

build()
